package com.moss.cloud.base.biz.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moss.cloud.base.api.model.param.LockPageParam;
import com.moss.cloud.base.api.model.vo.AccountLockHistoryRecordVO;
import com.moss.cloud.base.biz.mapper.AccountLockHistoryRecordMapper;
import com.moss.cloud.base.biz.model.AccountLockHistoryRecord;
import com.moss.cloud.base.biz.service.IAccountLockHistoryRecordService;
import com.moss.cloud.common.base.utils.PageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 账号锁定历史记录业务实现
 *
 * @author 瑾年
 * @date 2023年12月23日
 */
@Slf4j
@Service
public class AccountLockHistoryRecordServiceImpl extends ServiceImpl<AccountLockHistoryRecordMapper, AccountLockHistoryRecord> implements IAccountLockHistoryRecordService {

    /**
     * 账号锁定历史记录分页
     *
     * @param pageParam
     * @return
     */
    @Override
    public IPage<AccountLockHistoryRecordVO> recordPage(LockPageParam pageParam) {
        Page<AccountLockHistoryRecord> page = PageUtil.createPage(pageParam.getCurrent(), pageParam.getSize());
        return this.baseMapper.historyRecord(page,pageParam);
    }

    /**
     * 新增锁定历史记录
     *
     * @param accountLockHistoryRecord
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean addHistoryRecord(AccountLockHistoryRecord accountLockHistoryRecord) {
        return this.save(accountLockHistoryRecord);
    }
}
